//
//  Explosion.m
//  MyFirstGame
//
//  Created by Thi Huynh on 3/1/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "Explosion.h"

@implementation Explosion
-(id) init
{
	return [self initWithTotalParticles:20];
}

-(id)initExplosionWithColor:(ccColor3B)color WithPosisiton:(CGPoint)position
{
    if( (self=[super initWithTotalParticles:15]) ) 
    {
        
		// duration
		duration = kCCParticleDurationInfinity;
		
		self.emitterMode = kCCParticleModeGravity;
        
		// Gravity Mode: gravity
		self.gravity = ccp(0,0);
		
		// Gravity Mode: speed of particles
		self.speed = 30;
		self.speedVar = 25;
		
		// Gravity Mode: radial
		self.radialAccel = 0;
		self.radialAccelVar = 0;
		
		// Gravity Mode: tagential
		self.tangentialAccel = 0;
		self.tangentialAccelVar = 0;
		
		// angle
		//angle = 270;
		//angleVar = 10;
        
		// emitter position
		self.position = ccp(position.x, position.y);
		posVar = CGPointZero;
		
		// life of particles
		life = 1.5;
		lifeVar = 2.0f;
		
		// size, in pixels
		startSize = 15;
		startSizeVar = 5;
        
		endSize = 2;
        
		// emits per second
		emissionRate = totalParticles/duration;
		
		// color of particles
		startColor.r = color.r;
		startColor.g = color.g;
		startColor.b = color.b;
		startColor.a = 1.0f;
        
//        startColorVar=startColor;
//        endColor=startColor;
//        endColorVar=startColor;
		
		self.texture = [[CCTextureCache sharedTextureCache] addImage:@""];
        
		// additive
		self.blendAdditive = YES;
	}
	
	return self;
    
}
/*
-(id) initWithTotalParticles:(NSUInteger)p
{
	if( (self=[super initWithTotalParticles:p]) ) {
        
		// duration
		duration = 0.1f;
		
		self.emitterMode = kCCParticleModeGravity;
        
		// Gravity Mode: gravity
		self.gravity = ccp(0,0);
		
		// Gravity Mode: speed of particles
		self.speed = 70;
		self.speedVar = 40;
		
		// Gravity Mode: radial
		self.radialAccel = 0;
		self.radialAccelVar = 0;
		
		// Gravity Mode: tagential
		self.tangentialAccel = 0;
		self.tangentialAccelVar = 0;
		
		// angle
		angle = 90;
		angleVar = 360;
        
		// emitter position
		CGSize winSize = [[CCDirector sharedDirector] winSize];
		self.position = ccp(winSize.width/2, winSize.height/2);
		posVar = CGPointZero;
		
		// life of particles
		life = 2.0f;
		lifeVar = 1;
		
		// size, in pixels
		startSize = 15.0f;
		startSizeVar = 10.0f;
        
		endSize = kCCParticleStartSizeEqualToEndSize;
        
		// emits per second
		emissionRate = totalParticles/duration;
		
		// color of particles
		startColor.r = 0.7f;
		startColor.g = 0.1f;
		startColor.b = 0.2f;
		startColor.a = 1.0f;
        
		startColorVar.r = 0.5f;
		startColorVar.g = 0.5f;
		startColorVar.b = 0.5f;
		startColorVar.a = 0.0f;
		
        endColor.r = 0.5f;
		endColor.g = 0.5f;
		endColor.b = 0.5f;
		endColor.a = 0.0f;
		
        endColorVar.r = 0.5f;
		endColorVar.g = 0.5f;
		endColorVar.b = 0.5f;
		endColorVar.a = 0.0f;
		
		self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"];
        
		// additive
		self.blendAdditive = YES;
	}
	
	return self;
}
*/
@end
